Skip to content

refactor: DRY audit page layout wrapper#47

Open
somethingwithproof wants to merge 1 commit intoCacti:developfrom
somethingwithproof:fix/dry-layout-46
Open

refactor: DRY audit page layout wrapper#47
somethingwithproof wants to merge 1 commit intoCacti:developfrom
somethingwithproof:fix/dry-layout-46

Conversation

@somethingwithproof
Copy link

Summary

  • add shared audit_render_with_layout() helper for page wrapper rendering
  • route wrapped audit action paths through the helper
  • preserve behavior while removing duplicated top_header()/bottom_footer() wrapper logic

Tests

  • php -l audit.php
  • php -l ui_helpers.php
  • php -l tests/test_layout_wrapper.php
  • php tests/test_layout_wrapper.php

Closes #46

Copilot AI review requested due to automatic review settings March 15, 2026 23:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the audit plugin UI controller to remove duplicated top_header() / bottom_footer() page-wrapping logic by introducing a shared layout wrapper helper and routing relevant actions through it.

Changes:

  • Added audit_render_with_layout() helper to centralize audit page layout wrapping.
  • Updated audit.php routing to use the shared wrapper for the purge and default paths.
  • Added a standalone regression test to validate wrapper call ordering and ensure the routing uses the helper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
ui_helpers.php Introduces shared audit_render_with_layout() wrapper around top_header() / renderer / bottom_footer().
audit.php Includes the helper and routes wrapped actions through it to eliminate duplicated layout code.
tests/test_layout_wrapper.php Adds a lightweight regression script checking wrapper sequencing and basic routing wiring.

You can also share your feedback on Copilot code review. Take the survey.

*/

if (!function_exists('audit_render_with_layout')) {
function audit_render_with_layout($renderer) {
Comment on lines +53 to +59
assert_true(
'purge/default actions use shared layout helper',
substr_count($source, "audit_render_with_layout('audit_log');") >= 2
);
assert_true(
'audit.php includes ui helper file',
strpos($source, "include_once('./plugins/audit/ui_helpers.php');") !== false
Comment on lines +62 to +65
echo "\n";
echo "Results: $pass passed, $fail failed\n";

exit($fail > 0 ? 1 : 0);
Comment on lines +6 to +11
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
+-------------------------------------------------------------------------+
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: DRY audit page layout wrapper

2 participants